<!DOCTYPE html>
<html lang="en"><!-- InstanceBegin template="/Templates/MainTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
<!-- #BeginEditable "doctitle" -->
<title>Step by Step develop a Jdon application with jdon-struts1x</title>  
<!-- #EndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <!-- Bootstrap core CSS -->
     <link rel="stylesheet" href="css/bootstrap.min.css">   

    <!-- Custom styles for this template -->
    <link href="css/starter-template.css" rel="stylesheet">

   <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->    
  </head>
<body>
 <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.html">Jdon Framework</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
                <li class="active"><a href="index.html">Home</a></li>
               <li><a href="https://sourceforge.net/projects/jdon/files/">Download</a></li>
               <li><a href="doc.htm" >Document</a></li>
               <li><a href="quickconf.html">Qucik Start</a> </li>
               <li><a href="examples.html">Examples</a></li>
               <li ><a href="https://github.com/banq/jdonframework">Github</a></li>
               <li><a href="articles.html">Articles</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </div>
    

    <div class="container">
     <div class="starter-template">     
    
 <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">  
  <tr>     
    <td bgcolor="#FFFFFF"  valign="top" align="left">

                  
				<!-- #BeginEditable "main" --> 
                  <p>　　</p>
                  <h1 align="center">Step by Step develop a Jdon application with jdon-struts1x</h1>
                  <p>&nbsp;</p>
                  <ol>
                    <li><a href="quickconf.html" target="_blank">Quick starting configuration(for xml) </a></li>
                    <li><a href="#crud">Create/Read/Update/Delete(CRUD) of the Model</a>;</li>
                    <li> <a href="#batch">Batch inquiry and multi-page display</a></li>
                  </ol>
                  <p>this document will show you how to develop these functions by Jdon Framework.<br>
                    the source of this document's sample is the package of JdonCRUDsample.rar or jdonsample.rar.</p>
                  <p>this is no Domain Events or DCI.</p>
                  <p><a href="#batch"></a><a href="http://www.jdon.com:8080/testWeb/" target="_blank">DEMO Example</a></p>
                  <p><a href="http://www.jdon.com/jdonframework/train.rar">Source Download </a></p>
                  <p>let's begin...</p>
                  <h3><strong><a name="crud"></a>Step By Step develop CRUD function</strong></h3>
                  <p>In CRUD developing process there are two parts that are  coding and configuration. </p>
                  <h4>Coding:</h4>
                  <blockquote>
                    <p>In coding phase there are 3 steps:<br>
                      <strong>1</strong>. create a Model class code: sample.model.Message, it's content is below:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>//@Model<br>
                        public class Message extends <strong>Model</strong> {<br>
                        &nbsp;&nbsp;&nbsp;private Long messageId;<br>
                        &nbsp;&nbsp;&nbsp;private String name;</p>
                        <p> &nbsp;&nbsp;&nbsp;public String getName() {    return name;  }<br>
                          &nbsp;&nbsp;&nbsp;public void setName(String name) {    this.name = name;  }<br>
                          }</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> note:</p>
                    <ul>
                      <li>the class must be annotated by Model annotation ,or extends com.jdon.controller.model.Model of the jdon framework,
                        or implements the interface:com.jdon.controller.model.ModelIF.</li>
                      <li> the class must have a unique key/primary key so can indicate a object, the key is equals
                        to the primary ke of the table in database.</li>
                    </ul>
                    <p>enable Domain Model in memory, in persistence layer,such as jdbc:</p>
                    <table width="500" border="0" bordercolor="#CCCCCC">
                      <tr>
                        <td bgcolor="#CCCCCC"><p>@Component()<br>
                          @Introduce(&quot;modelCache&quot;)<br>
                          public class DAOJdbc implements MessageRepository{</p>
                          <p>&nbsp;&nbsp;&nbsp;@Around<br>
                            &nbsp;&nbsp;&nbsp;public Message getMessage(String Id) {</p>
                          <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...... //fetch from key-value stores or relation DB </p>
                          <p>&nbsp;&nbsp;&nbsp;}</p>
                          <p>}</p></td>
                      </tr>
                    </table>
                    <p><strong>2</strong>. create the service of the Model, a interface and a implements class of the interface,<br>
                      the interface is sample.service. MessageService:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>public interface MessageService {<br>
                        &nbsp;&nbsp;&nbsp;void createMessage(EventModel em); <br>
                        &nbsp;&nbsp;&nbsp;void updateMessage(EventModel em);<br>
                        &nbsp;&nbsp;&nbsp;void deleteMessage(EventModel em);<br>
                        &nbsp;&nbsp;&nbsp;Message getMessage(String messageId);<br>
                        }</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> you can creat the concrete class of the MessageService in any time, in this sample it is sample.service.MessageServiceImp</p>
                    <p><strong>3</strong>. create the UI form class:sample.web.MessageForm, the content of the class MessageForm
                      is same as the Model class sample.model.Message, the MessageForm's content can bigger than Message,</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>public class MessageForm extends <strong>ModelForm</strong> {</p>
                        <p> &nbsp;&nbsp;&nbsp;private String messageId;<br>
                          &nbsp;&nbsp;&nbsp;private String name;</p>
                        <p> &nbsp;&nbsp;&nbsp;public String getName() {    return name;  }<br>
                          &nbsp;&nbsp;&nbsp;public void setName(String name) {    this.name = name;  }<br>
                          }</p></td>
                    </tr>
                  </table>
                  <h4>configuration:</h4>
                  <blockquote>
                    <p> There are two steps:</p>
                    <ul>
                      <li> configure the relation of these class: Message/MessageService/MessageForm</li>
                      <li>configure page flow in the struts's struts-config.xml</li>
                    </ul>
                    <p><strong>Frist Step </strong>. the configuration about Jdon Framework
                      by the configuration we will create the relations among the Model Message. 
                      the MessageService and the UI form MessageForm, the relations will tell
                      Jdon Framework: this is a CRUD implemention about a Model.</p>
                    <p>this configuration is a XML file about Jdon Framework,so it's name can be 
                      jdonframework.xml, however we can change the name, but need tell Jdon the name.<br>
                      we can tell the name in struts-config.xml as below :</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>&lt;plug-in className=&quot;com.jdon.strutsutil.InitPlugIn&quot;&gt;<br>
                        &lt;set-property property=&quot;modelmapping-config&quot;  value=&quot;jdonframework.xml&quot; /&gt;<br>
                        &lt;/plug-in&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> so, when our project start, the jdonframework.xml configuration will be loaded by <br>
                      the Jdon Framework.</p>
                    <p>the content about jdonframework.xml as below:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p><br>
                        &lt;models&gt;<br>
                        &lt;!-- the Model class is sample.model.Message, and the primary key of the Model class is messageId --&gt;<br>
                        &nbsp;&nbsp;&nbsp;&lt;model key=&quot;messageId&quot; class =&quot;sample.model.Message&quot;&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- configuration  about UI Form: MessageForm --&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;actionForm name=&quot;messageForm&quot;/&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;handler&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- configuration  about  the Model service : MessageService --&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;service ref=&quot;messageService&quot;&gt; <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;getMethod name=&quot;getMessage&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;createMethod name=&quot;createMessage&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;updateMethod name=&quot;updateMessage&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;deleteMethod name=&quot;deleteMessage&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/service&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/handler&gt;<br>
                        &nbsp;&nbsp;&nbsp;&lt;/model&gt;</p>
                        <p> &nbsp;&nbsp;&nbsp;......<br>
                          &lt;/models&gt;<br>
                          &lt;services&gt;<br>
                          &nbsp;&nbsp;&nbsp;&lt;!-- the Ioc configuration about MessageService --&gt;<br>
                          &nbsp;&nbsp;&nbsp;&lt;pojoService name=&quot;messageService&quot; class=&quot;sample.service.MessageServiceImp&quot;/&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;......<br>
                          &lt;/services&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> we will show how to configure those lines in jdonframework.xml</p>
                    <p><strong>One. Model's configuration</strong>:<br>
                      this line will define a Model class and its primary filed:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>&lt;model key=&quot;messageId&quot; class =&quot;sample.model.Message&quot;&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> messageId is a field of the class: sample.model.Message, and one messageId'value<br>
                      indicate unique one object of the Model class Message. the messageId can be the <br>
                      Object ID, some like the primary key of a table.
                      String is recommended for the type of primary key.</p>
                    <p><strong>Two. MessageForm's configuration:</strong></p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>&lt;actionForm name=&quot;messageForm&quot;/&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> messageForm is the name of the class sample.web.MessageForm, but where the name is defined?
                      it is defined in struts-config.xml, such as :</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p>&lt;struts-config&gt;<br>
                        &nbsp;&nbsp;&nbsp;&lt;form-beans&gt;&nbsp;&nbsp;&nbsp;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;form-bean name=&quot;messageForm&quot; type=&quot;sample.web.MessageForm&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;…… <br>
                        &nbsp;&nbsp;&nbsp;&lt;/form-beans&gt;<br>
                        
                        ….. <br>
                        &lt;/struts-config&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p><strong>Three. MessageService's configuration:</strong><br>
                      in jdonframework.xml, we will declare the POJO service,
                      we can define the name of the class sample.service.MessageServiceImp is 'messageService'.</p>
                    <p>&lt;pojoService name=&quot;messageService&quot; class=&quot;sample.service.MessageServiceImp&quot;/&gt;</p>
                    <p><br>
                      if there any dependences in MessageServiceImp, we only configure the dependent class in here, if the
                      dependent class is a Dao class, so we can configure the Dao class as below:</p>
                    <p>&lt;component name=&quot;messageDao&quot; class=&quot;sample.dao.hibernate.MessageDaoHB&quot; &gt;<br>
                      &lt;constructor value=&quot;java:/TestDS&quot;/&gt;<br>
                      &lt;/component&gt;<br>
                      <br>
                      ok, let's go back the CRUD configuration, after the POJO service name is configured,
                      so we must tell Jdon Framework the service's method names about CRUD operations.</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p><br>
                        &lt;handler&gt;<br>
                        &nbsp;&nbsp;&nbsp;&lt;!-- this will refer to service: messageService--&gt;&nbsp;&nbsp;&nbsp;<br>
                        &nbsp;&nbsp;&nbsp;&lt;service ref=&quot;messageService&quot;&gt; <br>
                        <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--getMessage is the method name of MessageService --&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;getMethod name=&quot;getMessage&quot; /&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--createMessage is the method name of MessageService --&gt;<br>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;createMethod name=&quot;createMessage&quot; /&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--updateMessage is the method name of MessageService --&gt;<br>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;updateMethod name=&quot;updateMessage&quot; /&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!--deleteMessage is the method name of MessageService --&gt;<br>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;deleteMethod name=&quot;deleteMessage&quot; /&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/service&gt;<br>
                          &lt;/handler&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> those methods are actually the name of the interface sample.service. MessageService too.</p>
                    <p>let's step into the second part of the CRUD configuration! </p>
                    <p><strong>Second Step </strong>.<strong>: </strong>page flow in struts-config.xml<br>
                      there are two page flows in the CRUD<strong>:</strong></p>
                    <p><strong>One. </strong> the server will push a page that user will create/update to the client .<br>
                      we can configure a action and jsp in struts-config.xml:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p><br>
                        &lt;action name=&quot;messageForm&quot; path=&quot;/messageAction&quot; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=&quot;com.jdon.strutsutil.ModelViewAction&quot;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scope=&quot;request&quot; validate=&quot;false&quot;&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;forward name=&quot;create&quot; path=&quot;/message.jsp&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;forward name=&quot;edit&quot; path=&quot;/message.jsp&quot; /&gt;<br>
                        &lt;/action&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> the type value &quot;com.jdon.strutsutil.ModelViewAction&quot; is the implemention of Jdon Framework.</p>
                    <p>when the users call http://localhost:8080/messageAction.do, ModelViewAction will be active, and 
                      will enter the &quot;create&quot; flow of the 'forward', and the server will push '/message.jsp'.</p>
                    <p>when the users call http://localhost:8080/messageAction.do?action=edit&amp;messageId=18, ModelViewAction
                      will enter the &quot;edit&quot; flowof the 'forward', and the server will push  '/message.jsp' that contains a 
                      existed old datas, so the users can update those old form datas.</p>
                    <p>there a coding rule in /message.jsp, as below:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p><br>
                        &lt;html:form action=&quot;/messageSaveAction.do&quot; method=&quot;POST&quot; &gt;</p>
                        <p>&lt;html:hidden property=&quot;action&quot;/&gt; &lt;!--  this is a rule --&gt;</p>
                        <p> MessageId：&lt;html:text property=&quot;messageId&quot;/&gt;<br>
                          &lt;br&gt;Name：&lt;html:text property=&quot;name&quot;/&gt;<br>
                          &lt;br&gt;&lt;html:submit property=&quot;submit&quot; value=&quot;Submit&quot;/&gt;<br>
                          &lt;/html:form&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p><br>
                      in the message.jsp, there is a hidden field named &quot;action&quot;. this is a rule of CRUD<br>
                      when the page was submited, that will active '/messageSaveAction.do', this is <br>
                      about next flow configuration:</p>
                    <p><strong>Two</strong> the server should accept the submited datas in the last page, as below:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr>
                      <td><p><br>
                        &lt;action name=&quot;messageForm&quot; path=&quot;/messageSaveAction&quot; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=&quot;com.jdon.strutsutil.ModelSaveAction&quot;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scope=&quot;request&quot; validate=&quot;true&quot; input=&quot;/message.jsp&quot;&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;forward name=&quot;success&quot; path=&quot;/result.jsp&quot; /&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;forward name=&quot;failure&quot; path=&quot;/result.jsp&quot; /&gt;<br>
                        &lt;/action&gt;</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p> com.jdon.strutsutil.ModelSaveAction is another implementions of Jdon Framework.<br>
                      'ModelSaveAction' will delegate 'ModelHandler' (default it is XMLModelHandler) call 
                      the service, in the '&lt;handler&gt;&lt;/handler&gt;'  of the jdonframework.xml, we have configured
                      the CRUD method of your server as above.</p>
                  </blockquote>
                  <p>so, we finish the CRUD development.<br>
                  </p>
                  <p><strong><a name="batch"></a>Step By Step develop Batch Inquiry and muilt-pages Display function</strong></p>
                  <h4>Coding:</h4>
                  <blockquote>
                    <p>In this phase there are three steps:</p>
                    <p><strong>First Step</strong>. code a query class that implements  com.jdon.strutsutil.ModelListAction, the class named sample.web.MessageListAction, in this class we must implements two methods: 'getPageIterator' and 'findModelByKey'.</p>
                    <p>'getPageIterator' method will call the MessageService:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        MessageService messageService = (MessageService) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebAppUtil.getService(&quot;messageService&quot;,request);<br>
                        return messageService.getAllMessages(start, count);</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p>the interface                     MessageService must have the getAllMessages mehtod that by yourself implement. </p>
                    <p>'findModelByKey' method will call the getMessage of the service: </p>
                    <table width="100%" border="0" bgcolor="#CCCCCC">
                      <tr bgcolor="#CCCCCC">
                        <td><p><br>
                          MessageService messageService = (MessageService)  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebAppUtil.getService(&quot;messageService&quot;, request);<br>
                          return messageService.<strong>getMessage</strong>((String)key);</p></td>
                      </tr>
                    </table>
                    <p><strong>Second Step</strong>: Implement the getAllMessages in Service layer, we will call the MessageDao to implement the function (see the source), </p>
                    <p><strong>Third Step</strong>: In MessageDao we create a PageIterator object and return it ,this can done by Jdon Frameowork.</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        public PageIterator getMessages(int start, int count) throws Exception {<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String GET_ALL_ITEMS_ALLCOUNT = &quot;select count(1) from testmessage &quot;;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String GET_ALL_ITEMS = &quot;select messageId  from testmessage &quot;;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return pageIteratorSolver. getPageIterator (GET_ALL_ITEMS_ALLCOUNT, <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GET_ALL_ITEMS, &quot;&quot;,start, count);<br>
                        }</p></td>
                    </tr>
                  </table>
                  <blockquote>
                    <p>if there are method parameters, we can implement them as below:</p>
                  </blockquote>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        public PageIterator getMessages(Long categoryId, int start, int count) {<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String GET_ALL_ITEMS_ALLCOUNT =<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;select count(1) from message where categoryId = ? &quot;;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String GET_ALL_ITEMS = <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;select messageId  from message where categoryId = ? &quot;;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Collection params = new ArrayList(1);<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params.add(categoryId);//paramters will be put into Collection<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return pageIteratorSolver.getPageIterator(GET_ALL_ITEMS_ALLCOUNT, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GET_ALL_ITEMS, params, start, count);<br>
                        }</p></td>
                    </tr>
                  </table>
                  <blockquote>&nbsp;</blockquote>
                  <p>Configuration One:</p>
                  <p> JdonFramework's configuration, we need put our POJO component into Ioc container, so we can call them in coding, this step is same as CRUD. </p>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        &lt;services&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;pojoService name=&quot;messageService&quot; class=&quot;sample.service.MessageServiceImp&quot;/&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;component name=&quot;messageDAO&quot; class=&quot;sample.dao.MessageDAO&quot;/&gt; <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;component name=&quot;constants&quot; class=&quot;sample.Constants&quot;&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;constructor value=&quot;java:/TestDS&quot;/&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/component&gt; <br>
                        &lt;/services&gt;</p></td>
                    </tr>
                  </table>
                  <p>in the MessageServiceImp, there are such construct method:</p>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        public class MessageServiceImp implements MessageService{</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private MessageDAO messageDAO;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public MessageServiceImp(MessageDAO messageDAO){</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.messageDAO = messageDAO;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
                        <p>}</p></td>
                    </tr>
                  </table>
                  <p>the dependencs between MessageService with MessageDAO will be solved by Jdon Ioc container.</p>
                  <p>Configuration Two: </p>
                  <p>this step is a normal struts action configurtion , as below: </p>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        &lt;form-beans&gt;<br>
                        
                        ……<br>
                        &lt;form-bean name=&quot;listForm&quot; type=&quot;com.jdon.strutsutil.ModelListForm&quot; /&gt;<br>
                        &lt;/form-beans&gt;</p></td>
                    </tr>
                  </table>
                  <p>com.jdon.strutsutil.ModelListForm is the default class of Jdon Framework, we configure action: </p>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        &lt;action name=&quot;listForm&quot; path=&quot;/messageListAction&quot; <br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=&quot;sample.web.MessageListAction&quot; scope=&quot;request&quot;&gt;<br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;forward name=&quot;success&quot; path=&quot;/messageList.jsp&quot; /&gt;<br>
                        &lt;/action&gt;</p></td>
                    </tr>
                  </table>
                  <p><br>
                    sample.web.MessageListAction is our implements as above.</p>
                  <p>when the users browse http://localhost:8080/ messageListAction.do, they will see the all messages items sist, default count is 30 .</p>
                  <p>in the  messageList.jsp we need add the multi-pages tag:</p>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        &lt;MultiPages:pager actionFormName=&quot;listForm&quot; page=&quot;/messageListAction.do&quot;&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;MultiPages:prev name=&quot;[Prev ]&quot; /&gt;<br>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;MultiPages:index displayCount=&quot;1&quot; /&gt;<br>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;MultiPages:next  name=&quot;[Next ]&quot; /&gt;<br>
                          &lt;/MultiPages:pager&gt;</p></td>
                    </tr>
                  </table>
                  <p>&nbsp;</p>
                  <p>and in the messageList.jsp we can get a Message object by the tag &quot;logic:iterator&quot; :</p>
                  <table width="100%" border="0" bgcolor="#CCCCCC">
                    <tr bgcolor="#CCCCCC">
                      <td><p><br>
                        &lt;logic:iterate indexId=&quot;i&quot;   id=&quot;message&quot; name=&quot;listForm&quot; property=&quot;list&quot; &gt; </p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean:write name=&quot;message&quot; property=&quot;name&quot; /&gt;</p>
                        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.........</p>
                        <p>&lt;/logic:iterate</p></td>
                    </tr>
                  </table>
                  <p>&nbsp;</p>
                  <p>We finish the Batch Inquiry and muilt-pages Display function! All source code can download by <a href="http://www.jdon.com/jdonframework/train.rar">click here</a>, and the running demo <a href="http://www.jdon.com:8080/testWeb/" target="_blank">click here</a></p>
                  <p></p>
                  <p>&nbsp;</p>
                  <!-- #EndEditable -->
                 
			  	
          </td>
		  <td width="340" valign="top"  bgcolor="#FFFFD7"> 
          <div class="adsensf" id="vgad336x280">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 页上左336 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-7573657117119544"
     data-ad-slot="6751585519"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 页上左336 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-7573657117119544"
     data-ad-slot="6751585519"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>         
 </td>
  </tr>
</table>


<table width="100%" border="0" cellspacing="0" cellpadding="0" height="2" bgcolor="#000000"  align="center">
              <tr>
                <td></td>
              </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td height="20" bgcolor="#CAC9BB" align="center">
  
  </td>
</tr>
</table>
 </div>
</div><!-- /.container -->

<!-- InstanceBeginEditable name="EditRegion3" --><!-- InstanceEndEditable -->
        <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
<!-- AddThis Smart Layers BEGIN -->
<!-- Go to http://www.addthis.com/get/smart-layers to customize -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-52c4b79515624135"></script>
<script type="text/javascript">
  addthis.layers({
    'theme' : 'transparent',
    'share' : {
      'position' : 'left',
      'numPreferredServices' : 5
    },  
    'whatsnext' : {},  
    'recommended' : {} 
  });
</script>
<!-- AddThis Smart Layers END -->    
</body>
<!-- InstanceEnd --></html>
